import { test, expect } from "@playwright/test";

test("通过JWT访问受限页面", async ({ page, context }) => {
  // 1. 设置JWT作为Cookie

  // 2. 导航到目标页面
  await page.goto(
    "https://passport.damai.cn/login?ru=https%3A%2F%2Fwww.damai.cn%2F",
    {
      waitUntil: "networkidle",
      timeout: 20000000,
    }
  );

  await page.waitForLoadState("networkidle"); // 等待所有请求静止
  // 本地存储数据
  await page.evaluate(() =>
    localStorage.setItem(
      "vben-web-ele-5.5.2-dev-core-access",
      JSON.stringify({
        accessToken:
          "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NTQ1NDk4MjMsImlhdCI6MTc1NDQ2MzQyMywidXNlcklkIjoxfQ.TETMedfQU58eUO7KTZd6DX0c86E9TL_ltkTjuZvAT8g",
        refreshToken:
          "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE3NTk2NDc0MjMsImlhdCI6MTc1NDQ2MzQyMywidXNlcklkIjoxfQ.JxBO1Kme6OF9FLcPGNH5-fJm7ht_r7kA1dvkonhBo9c",
        accessCodes: [],
      })
    )
  );

  await page.waitForTimeout(50000);
});
